package com.ynu.yx.chatroleai.utils;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration // 标识配置类
@EnableSwagger2 // 启用Swagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ynu.yx.chatroleai.controller")) // 指定扫描的包
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact(
                "于秋", "http://123:54/yuqiu.com", "yuqiu@111.com"

        );
        return new ApiInfoBuilder()
                .title("API文档")
                .description("AI聊天")
                .termsOfServiceUrl("http://localhost:8080/")
                .version("1.0.0.0")
                .license("MLA")
                .licenseUrl("https://www.mla.com.cn/")
                .contact(contact)
                .build();
    }
}
